package controller

import (
	"github.com/gin-gonic/gin"
	"shop-bean/dto"
	"shop-common/library/serializer"
	"shop-common/utils"
	"shop-common/utils/queryWrapper"
	"shop-service/business"
)

type IndexImgController struct{}

// @Tags 首页轮播图接口
// @description: 首页轮播图
// @Summary 获取首页轮播图列表信息
// @function: IndexImgs
// @Accept  json
// @Produce  json
// @Success 200 {object} string "{"code":1," result":{}, "message":"操作成功", "time":1618493448}"
// @Router /indexImgs [get]
func (c *IndexImgController) IndexImgs(ctx *gin.Context) {
	indexImgList, err := business.ServiceImpl().IndexImgService.Find(ctx, queryWrapper.Eq("status", 2))
	if err != nil {
		serializer.Fail(ctx, serializer.PublicQueryErr)
		return
	}

	var result []*dto.IndexImgDto
	utils.StructMap(indexImgList, &result)
	serializer.SuccessData(ctx, "", result)
}
